import request from '@/config/axios'
//import {OEEChart} from '@/views/dppBoard/factoryPerformance/echarts-data'
// 工作站 VO
export interface InfraWorkcenterVO {
  id: number // 编号
  parentId: number // 父工作站ID
  sapId: string // sap中的编号
  picture: string // 图片url
  description: string // 简要描述
}

//KPI数据类
export interface ContentData {
  id: number             // id
  type:string            // 类型：charts |  img  |  checklist(日检表)  
  contenttitle: string   // 小标题
  echartData?:object        // 后台传输的图表数据
  echartoptions?:object     // options - echart图表（在前端进行配置） 
  pyramidtableData?: any[] // 安全金字塔表格data    
  inspectionData?:any[]    // 日检表数据
  topissue?:any[]         // 日检表对应的top issuse
  imgaddress?:string     // 图片路径
  carousel?:any[]        // 图片路径数组 - 走马灯（图片切换）
}

// 工作站 API
export const InfraWorkcenterApi = {
  // 查询工作站列表
  getInfraWorkcenterList: async (params) => {
    return await request.get({ url: `/manu/infra-workcenter/list`, params })
  },

  // 查询工作站详情
  getInfraWorkcenter: async (id: number) => {
    return await request.get({ url: `/manu/infra-workcenter/get?id=` + id })
  },

  // 新增工作站
  createInfraWorkcenter: async (data: InfraWorkcenterVO) => {
    return await request.post({ url: `/manu/infra-workcenter/create`, data })
  },

  // 修改工作站
  updateInfraWorkcenter: async (data: InfraWorkcenterVO) => {
    return await request.put({ url: `/manu/infra-workcenter/update`, data })
  },

  // 删除工作站
  deleteInfraWorkcenter: async (id: number) => {
    return await request.delete({ url: `/manu/infra-workcenter/delete?id=` + id })
  },

  // 导出工作站 Excel
  exportInfraWorkcenter: async (params) => {
    return await request.download({ url: `/manu/infra-workcenter/export-excel`, params })
  },

  //测试方法
  trialGetData: () => {

    const OriginalData:ContentData[]= [

      {
        id: 1, // id
        type:'charts',
        contenttitle: '安全金字塔', // 小标题
        pyramidtableData: [
          {
          month: 0,
          YTD: 0,
          
          },
          {
            month: 0,
            YTD: 0,
            
          },
          {
            month: 0,
            YTD: 0,
            
          },
          {
            month: 0,
            YTD: 0,
            
          },
          {
            month: 17,
            YTD: 60,
            
          },
        ],  
        
      },
      {
        id: 2, // id
        type:'charts',
        contenttitle: '首次通过率(FPY%)', // 小标题
        
        echartData:{
          
          target:[98],
          data: [
            98,96.45,97,98,98
          ],
          
          
          // area:'BV',
          // BVtarget:98,
          // BVdata: [
          //   98,96.45,97,98,98
          // ],

          // area:'HM',
          // HMtarget:99,
          // HMdata: [
          //   98,96.45,97,98,96
          // ],
        },
      },
      {
        id: 3, // id
        type:'charts',
        contenttitle: '交货可靠率', // 小标题
        //echartoptions:QualityFPY,
        echartData:{

          target:[96],
          data: [
            98,96.7,97,96,96
          ],
          
        },

      },

      {
        id: 4, // id
        type:'charts',
        contenttitle: '生产率', // 小标题
        echartData:{
          
          target:[12.6],
          data: [
            12.8,12.7,12.6,12.9,12.7
          ],
  
        },
      },

      {
        id: 5, // id
        type:'img',
        contenttitle: '周报', // 小标题
        //echartoptions:QualityFPY,
        imgaddress:'/WeeklyReport.png'
        },
      {
        id: 6, // id
        type:'charts',
        contenttitle: '潜在风险&虚惊事件', // 小标题
        //echartoptions:DailyShiftChart,
        echartData:{
          
          //代表Near Miss(**特殊**)--bar图
          data: [
            1,2,1,3
          ],

          //代表Pot. Hazards(**特殊**)-line图
          target:[2,1,4,2],

        },
      },
      {
        id: 7, // id
        type:'charts',
        contenttitle: '报废数量', // 小标题
        //echartoptions:QualityFPY,
        echartData:{
          
          data: [
            14,2,1,13
          ],

          
          target: [],
        },
      },
      {
        id: 8, // id
        type:'charts',
        contenttitle: '实际产出', // 小标题
        //echartoptions:QualityFPY,
        echartData:{
          
          target:[1000],
          data: [
            900,1000,1100,1300
          ],
          
        }
      },
      {
        id: 9, // id
        type:'charts',
        contenttitle: '人员安排', // 小标题
        //echartoptions:QualityFPY,
        echartData:{
          
          //target FTE - line
          target:[35],
          //缺勤 - line
          absent:[4,2,1,4],

          //actual FTE -bar
          data: [
            30,40,40,35
          ],

          //加班 -bar
          overtime: [
            7,5,0,4
          ],
        }

      },
      {
        id: 10, // id
        type:'carousel',
        contenttitle: 'COPQ/OEE分析', // 小标题
        carousel:[{id:0,url:'/CopqAnalysis.png'},{id:1,url:'/RedAlart.png'}]
        //echartoptions:OEEChart,
        // echartData:{

        //   area:'PLANT',
        //   OEExAxis:['BV equipment issue', 'HM supplier issue', 'HM undefined cost',"HM..."],
        //   BVdata: [50, 25, 12.5,12.5],
        //   BVtarget:[50,75,87.5,100],

        // }
        
      },
      {
        id: 11, // id
        type:'checklist',
        contenttitle: '安全日检', // 小标题
        //1:红,2：绿，3：空白
        inspectionData:[
          {
            checkpoints:'Daily Safety Walk', 
            MORNING1: 1, 
            MORNING2: 2,
            EVENING1: 1,
            EVENING2: 2,
          },
          {
            checkpoints:'5S Adherence',
            MORNING1: 2, 
            MORNING2: 1,
            EVENING1: 1,
            EVENING2: 2,
          },
          {
            checkpoints:'Safety',
            MORNING1: 1, 
            MORNING2: 2,
            EVENING1: 3,
            EVENING2: 3,
          },
          {
            checkpoints:'Right Tools,Right Use',
            MORNING1: 3, 
            MORNING2: 3,
            EVENING1: 1,
            EVENING2: 2,
          },
          
        ],
        topissue:[
          {
            shift:'MORNING',
            issue:'risk...',
            escalation:1,
          },
          {
            shift:'EVENING',
            issue:'no issue',
            escalation:2,
          }
        ]
      },
      {
        id: 12, // id
        type:'checklist',
        contenttitle: '质量日检', // 小标题
        //echartoptions:QualityFPY,
        inspectionData:[
          {
            checkpoints:'Supplier Parts Quality', 
            MORNING1: 1, 
            MORNING2: 2,
            EVENING1: 1,
            EVENING2: 2,
          },
          {
            checkpoints:'Equipment setup/Calibrated',
            MORNING1: 2, 
            MORNING2: 1,
            EVENING1: 1,
            EVENING2: 2,
          },
          {
            checkpoints:'Containment Inspections',
            MORNING1: 1, 
            MORNING2: 2,
            EVENING1: 3,
            EVENING2: 3,
          },
          {
            checkpoints:'Daily SOP Improvement',
            MORNING1: 3, 
            MORNING2: 3,
            EVENING1: 1,
            EVENING2: 2,
          },
          
        ],
        topissue:[
          {
            shift:'MORNING',
            issue:'risk...',
            escalation:1,
          },
          {
            shift:'EVENING',
            issue:'no issue',
            escalation:2,
          }
        ]
      },
      {
        id: 13, // id
        type:'checklist',
        contenttitle: '产出日检', // 小标题
        //echartoptions:QualityFPY,
        inspectionData:[
          {
            checkpoints:'Supplier Parts availability', 
            MORNING1: 1, 
            MORNING2: 2,
            EVENING1: 1,
            EVENING2: 2,
          },
          {
            checkpoints:'Bottleneck Performance',
            MORNING1: 2, 
            MORNING2: 1,
            EVENING1: 1,
            EVENING2: 2,
          },
          {
            checkpoints:'Line Balancing',
            MORNING1: 1, 
            MORNING2: 2,
            EVENING1: 3,
            EVENING2: 3,
          },
          {
            checkpoints:'NA',
            MORNING1: 3, 
            MORNING2: 3,
            EVENING1: 3,
            EVENING2: 3,
          },
          
        ],
        topissue:[
          {
            shift:'MORNING',
            issue:'risk...',
            escalation:1,
          },
          {
            shift:'EVENING',
            issue:'no issue',
            escalation:2,
          }
        ]
      },
      {
        id: 14, // id
        type:'checklist',
        contenttitle: '效率日检', // 小标题
        //echartoptions:QualityFPY,
        inspectionData:[
          {
            checkpoints:'100% Trained resources', 
            MORNING1: 1, 
            MORNING2: 2,
            EVENING1: 1,
            EVENING2: 2,
          },
          {
            checkpoints:'IT / Systems',
            MORNING1: 2, 
            MORNING2: 1,
            EVENING1: 1,
            EVENING2: 2,
          },
          {
            checkpoints:'Breakdowns',
            MORNING1: 1, 
            MORNING2: 2,
            EVENING1: 3,
            EVENING2: 3,
          },
          {
            checkpoints:'Scrap / rework',
            MORNING1: 3, 
            MORNING2: 3,
            EVENING1: 1,
            EVENING2: 2,
          },
          
        ],
        topissue:[
          {
            shift:'MORNING',
            issue:'risk...',
            escalation:1,
          },
          {
            shift:'EVENING',
            issue:'no issue',
            escalation:2,
          }
        ]
      },
      {
        id: 15, // id
        type:'img',
        contenttitle: '生产计划', // 小标题
        //echartoptions:QualityFPY,
        imgaddress:'/CardBackground.png'  
        },
      {
        id: 16, // id
        type:'img',
        contenttitle: '红报', // 小标题
        //echartoptions:QualityFPY,
        imgaddress:'/RedAlart.png'
        },
      {
        id: 17, // id
        type:'img',
        contenttitle: '质量月报', // 小标题
        //echartoptions:QualityFPY,
        imgaddress:'/QualityReport.png'
        },
      {
        id: 18, // id
        type:'charts',
        contenttitle: '库存', // 小标题
        //echartoptions:QualityFPY,
        echartData:{
          
          week:['11','12','13','14'],
          target:[1551000],
          data: [
            1402479,1451996,1406577,1381471,1263720
          ],

        }

      },
      {
        id: 19, // id
        type:'img',
        contenttitle: '技能矩阵', // 小标题
        //echartoptions:QualityFPY,
        imgaddress:'/CardBackground.png'
          },
      {
        id: 20, // id
        type:'img',
        contenttitle: ' 空 ', // 小标题
        //echartoptions:QualityFPY,
        imgaddress:'/CardBackground.png'
          },

    ];
    
    return OriginalData;
      
    
  }
}
